package com.zyiot.Dao;

import com.zyiot.model.Replys;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class ReplysDao {
	private DBOpenHelper helper;
	private SQLiteDatabase db;

	public ReplysDao(Context context) {
		helper = new DBOpenHelper(context);
	}

	public void add() {
		db = helper.getWritableDatabase();
		db.execSQL("insert into e_Reply (rep_id,rep_state) values (1,0)");
	}

	public void update(Replys reply) {
		db = helper.getWritableDatabase();
		db.execSQL("update e_Reply set rep_state = ? where rep_id = 1", new Object[] { reply.getRep_state() });
	}
	
	public String getValue() {
		db = helper.getWritableDatabase();
		Cursor cursor = db.rawQuery("select rep_state from e_Reply where rep_id = 1", null);
		if (cursor.moveToNext()) {
			return cursor.getString(cursor.getColumnIndex("rep_state"));
		}
		return null;
	}
}
